<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Testimonial extends CI_Controller {

	function __construct(){
		  parent::__construct();
		  if(!isset($_SESSION)): session_start(); endif;
		  $this->load->model('users_model');
		  $this->load->model('recipients_model');
		  $this->load->model('messages_model');
		  $this->load->model('testimonial_model');
		  $this->load->helper('myuser_helper');
	}

	public function index()
	{
		$this->page();

	}

	function page($start_row=0){
		$limit = 2;
		if(trim($start_row) == ""){
			$start_row = 0;
		}
		$data['title']= "Testimonials";
		$data['main_content'] = 'misc/testimonial_view';

		//listing
		$testi_qry = $this->testimonial_model->getTestimonials();
		
		$data['posts_qry'] = $testi_qry;
		//pagination
		$this->load->library('pagination');
		$config['base_url'] = site_url('testimonial/page/');
		$config['total_rows'] = $testi_qry->num_rows();
		$config['per_page'] = $limit;
		$config['uri_segment'] = 3;
		$config['anchor_class'] = 'class="button pagi" ';
		$this->pagination->initialize($config);
		$data['pagination'] = $this->pagination->create_links();
		
		//ads
		$data['sidebar_ads'] = Myuser_helper::getAds('sidebar',2);
		$data['bottom_ads'] = Myuser_helper::getAds('bottom',1);
		$data['testi_qry_limited'] = $this->testimonial_model->getTestimonials_limited( $start_row, $limit );
		$this->load->view('includes/template', $data);
	}

	public function captcha_validate(){
	  $this->load->helper("captcha");
	  print_r(my_sessions());
	}

	function create_testimonials(){
		$query = $this->testimonial_model->addTestimonials();
		return $query;
	}

	function logout()
	{
		$this->session->sess_destroy();
		redirect('home');
	}


}// end of controller







